<template>
	<van-address-edit
		:area-list="areaList"
		show-set-default
		show-search-result
		:search-result="searchResult"
		:area-columns-placeholder="['请选择', '请选择', '请选择']"
		@save="onSave"/>
</template>

<script setup>
import { areaList } from '@vant/area-data'
import { getCurrentInstance } from 'vue';

const { proxy } = getCurrentInstance();

// 会员数据
const business = proxy.$cookies.get('business');

const searchResult = ref([]);

const onSave = async (info) => {
	const res = await proxy.$POST({
		url: '/address/add',
		params: {...info, busid: business.id}
	})

	if (res.code === 1) {
		proxy.$success(res.msg)
		// 返回上一页
		proxy.$router.back()
	} else {
		proxy.$fail(res.msg)
	}
}
</script>

<style scoped></style>
